package nowcoder.other.codem;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author fance
 * @date 2018/6/5 19:06
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int k = scanner.nextInt();
            int c = scanner.nextInt();
            int[] w = new int[m];
            double sum = 0;
            for (int i = 0; i < m; i++) {
                w[i] = scanner.nextInt();
                sum += w[i];
            }

            int[][] score = new int[n][m];
            int indexi = 0;
            int indexj = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    score[i][j] = scanner.nextInt();
                    if (score[i][j] == -1) {
                        indexi = i;
                        indexj = j;
                        score[i][j] = c;
                    }
                }
            }
            double[] realW = new double[m];
            for (int i = 0; i < m; i++) {
                realW[i] = w[i] / sum;
            }
            double[] res1 = new double[n];
            for (int x = 0; x < n; x++) {
                double cur = 0;
                for (int i = 0; i < m; i++) {
                    int max = score[i][0];
                    for (int j = 1; j < m; j++) {
                        max = Math.max(max, score[j][i]);
                    }
                    cur += (score[x][i] / max) * realW[i];
                }
                res1[x] = cur;
            }
            score[indexi][indexj] = 0;
            double[] res2 = new double[n];
            for (int x = 0; x < n; x++) {
                double cur = 0;
                for (int i = 0; i < m; i++) {
                    int max = score[i][0];
                    for (int j = 1; j < m; j++) {
                        max = Math.max(max, score[j][i]);
                    }
                    cur += (score[x][i] / max) * realW[i];
                }
                res2[x] = cur;
            }
            double[] tmp1 = res1.clone();
            Arrays.sort(tmp1);
            double k1 = tmp1[n - k];
            double[] tmp2 = res2.clone();
            Arrays.sort(tmp2);
            double k2 = tmp2[n - k];
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                if (res1[i] >= k1 && res1[i] >= k2) {
                    ret[i] = 1;
                } else if (res1[i] < k1 && res1[i] < k2) {
                    ret[i] = 2;
                } else {
                    ret[i] = 3;
                }
            }
        }
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int k = scanner.nextInt();
            int[] xiaomei = new int[k];
            int[] xiaotuan = new int[k];
            for (int i = 0; i < k; i++) {
                xiaomei[i] = scanner.nextInt();
                xiaotuan[i] = scanner.nextInt();
            }

           int res1 = m * xiaomei[0] + (n - m) * xiaotuan[0];
           int res2 = m * xiaomei[k - 1] + (n - m) * xiaotuan[k - 1];
           if (res1 >= res2) {
               System.out.print(k + " " + 0);
           } else {
               System.out.print(0 + " " + k);
           }
        }
    }*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[] a = new int[n];
            int[] flag = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
                flag[i] = scanner.nextInt();
            }
            int[] b = new int[m];
            int[] c = new int[m];
            for (int i = 0; i < m; i++) {
                b[i] = scanner.nextInt();
                c[i] = scanner.nextInt();
            }
            double res1 = 0;
            double sum = 0;
            // 有一个选择特价，就必须全选
            for (int i = 0; i < n; i++) {
                if (flag[i] == 1) {
                    res1 += Double.valueOf(a[i]) * 0.8;
                } else {
                    res1 += a[i];
                }
                sum += a[i];
            }
            double cur = 0;
            double res = res1;
            for (int i = 0; i < m; i++) {
                if (sum >= b[i]) {
                    cur = sum - c[i];
                }
                res = Math.min(res, cur);
            }
            System.out.printf("%.2f\n", res);
        }
    }*/

}

